home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Extensions / Imaging / Sane / demo.py next >
Encoding:
Text File  |  2000-06-23  |  746 b   |  31 lines

  1.  
  2. # Get the path set up properly
  3. import sys ; sys.path.append('.')
  4.  
  5. import sane
  6. print 'SANE version:', sane.init()
  7. print 'Available devices=', sane.get_devices()
  8.  
  9. scanner=sane.open('qcam:0x378')
  10. print 'SaneDev object=', scanner
  11. print 'Device parameters:', scanner.get_parameters()
  12.  
  13. # Set scan parameters
  14. scanner.contrast=170 ; scanner.brightness=150 ; scanner.white_level=190
  15. scanner.depth=6
  16. scanner.br_x=320 ; scanner.br_y=240
  17.  
  18. # Initiate the scan
  19. scanner.start()
  20.  
  21. # Get an Image object 
  22. # (For my B&W QuickCam, this is a grey-scale image.  Other scanning devices
  23. #  may return a 
  24. im=scanner.snap()
  25.  
  26. # Write the image out as a GIF file
  27. im.save('foo.gif')
  28.  
  29. # The show method() simply saves the image to a temporary file and calls "xv".
  30. #im.show()
  31.